#ifndef UI_KIT_H_
#define UI_KIT_H_
#include <vector>
#include "Core/Commons.h"

class NumberKit
{
public:
	NumberKit();
	~NumberKit() {}
	void Init(int val);
	void SetSpeed(float speed);
	bool Update(TimeStamp ts);
	int GetCurrentValue();
private:
	int Power10(int val);
	bool UpdateOnce(TimeStamp ts);
private:
	int m_val;
	float m_speed;
	int m_bits;
	std::vector<int> m_vals;
	std::vector<int> m_initVals;
	std::vector<int> m_changed;
};

class TimeKit
{
public:
	TimeKit();
	~TimeKit() {}
	void Init(int costTime);
	bool Update(TimeStamp ts);
	int GetCurrentValue();

	void SetSpeed(float speed);
private:
	float m_speed;
	int m_micro;
	int m_hour;
	int m_minute;
	int m_second;

	NumberKit m_microKit;
	NumberKit m_hourKit;
	NumberKit m_minuteKit;
	NumberKit m_secondKit;

	bool m_updateMicro;
	bool m_updateSecond;
	bool m_updateMinute;
	bool m_updateHour;
};

namespace SuccessLightStyle
{
	enum{
		EXPLOSION = 0,
	};
}

class CSprite;
class SuccessLightKit
{
public:
	SuccessLightKit();
	~SuccessLightKit();

	void Init(int style = SuccessLightStyle::EXPLOSION );
	void SetPosition(int x,int y);
	void Start();
	void Update(TimeStamp ts);
	void Draw();
	bool IsStartSuccessLight();
private:
	void DrawExplosion();
private:
	int m_SuccessLightMaxFrames;
	int m_successLightFrame;

	CSprite* m_spriteSuccess;

	int m_style;
	int m_posX;
	int m_posY;
};

class CSpriteInstance;
class ButtonHint2D
{
public:
	ButtonHint2D();
	~ButtonHint2D();

	void Init();
	void SetPosition(int x,int y);
	void Update(TimeStamp ts);
	void Draw();

	void Clear();

	int GetWidth();
	int GetHeight();
private:
	int m_posX;
	int m_posY;

	CSpriteInstance *m_pSprInstance;
};

class Animation2DHelper
{
public:
	Animation2DHelper();
	~Animation2DHelper();

	void Init(const char *pSpriteName, int animId);
	void SetPosition(int x,int y);
	void SetAlpha(int alpha);
	void Update(TimeStamp ts);
	void Draw();

	void Clear();

	bool IsAnimEnded();
private:
	int m_posX;
	int m_posY;

	int m_alpha;
	CSpriteInstance *m_pSprInstance;
};

class PowerFullAnimationHelper
{
public:
	PowerFullAnimationHelper();
	~PowerFullAnimationHelper();

	void Init();
	void Update(TimeStamp ts);
	void Draw();

	void SetPosition(int x, int y);
private:
	float m_nPowerFullFrame;
	int m_posX;
	int m_posY;
};

void RenderTexture(irr::video::ITexture *pTexture,irr::video::SMaterial *pMaterial, int x,int y, float fScale, float fAngle );

#endif//UI_KIT_H_